Numbering System
Objectives : Student should be able to -
Number Systems : Binary, Denary and Hexadecimal.
Q1. Why does any form of data (like text, graphics, audio or video) need to be converted into binary format to be processed by a computer?
Computer is made of silicon chips that contains millions and millions of transistors or switches, which could be in either 'ON' or 'OFF' state. A switch in 'ON' state is represented by '1' and 'OFF' state is represented by '0'.
These switches within a computer make use of Logic-gates to store and process data.
Computer can only understand binary digits called bits (1's and 0's), hence everything that need to be processed by computer has to be converted into Binary format.
Q2. Data is of mainly two types Analogue and Digital.
What is the difference between Analogue and Digital data?
Analogue data Digital dataAnalogue data is a continuous change of value
(like Wall Clock, temperature, pressure, ... etc.).Digital data is a discrete fixed set of values
(like 1, 2, 3, 4, ... so on).It keeps on changing over a period of time, which cannot be read accurately. It is a discrete value, which can be read accurately. It is a real value, represented by Sine Wave. It is a measure of analogue signal at a fixed time interval, represented by Square Wave.
Q3. Describe Binary number.
Q4. Describe Denary number.
Q5. Describe Hexadecimal number.
Q6. Explain the process of converting binary to denary number.
Example :-
Convert Binary number 1011012 into Denary.
Binary number 1 0 1 1 0 1 x x x x x xPlaceholder 32 16 8 4 2 1 = = = = = =Denary value 32 + 0 + 8 + 4 + 0 + 1= 4510
Q7. Explain the process of converting denary to binary number.
Example :-
Convert Denary number 3810 into Binary.
Headers (placeholders) 32 16 8 4 2 1 x x x x x xBinary number 1 0 0 1 1 0 = = = = = =Denary value 32 + 0 + 0 + 4 + 2 + 0= 38 Hence, denary number 3810 = 1 0 0 1 1 02 Binary value.
Q8. Explain the process of converting binary to hexadecimal number.
Example :-
Convert Binary number 1010011111012 into Hexadecimal.
Binary Number 1 0 1 0 0 1 1 1 1 1 0 1 8 4 2 1 8 4 2 1 8 4 2 1Denary value 10 7 13Hexadecimal digits A 7 DHence, binary number 1010011111012 = A7D16 Hexadecimal number.
Q9. Explain the process of converting denary to hexadecimal number.
Method-1 : Successive division by 16 until the value 0 is reached.
- Divide the denary number by 16, and write down the result and the remainder.
- Repeat the division until you get a result of 0.
- Convert the denary remainder to their hexadecimal equivalent.
- Write the remainder in reverse (from the last calculated remainder to the first) to get the final result.
Example :-
Convert Denary number 145210 into Hexadecimal.
Divisor Denary value / Quotient Remainder Hex-digit 16 1452 16 901452 - 1440 = 12 C 16 590 - 80 = 10 A 05 - 0 = 5 5
Method-2 : Convert denary-to-binary and then binary-to-hexadecimal.
- Convert denary into binary.
- Group the binary bits in 4 from right to left.
- Convert each group of 4-bits into denary.
- Then convert each denary value to hexadecimal digits.
- The combination of hex-digits is equivalent to the given denary number.
Example :-
Convert Denary number 145210 into Hexadecimal.
1452 - 1024 = 428
428 - 256 = 172
172 - 128 = 44
44 - 32 = 12
12 - 8 = 4
Placeholder 2048 1024 512 256 128 64 32 16 8 4 2 1Binary digits 0 1 0 1 1 0 1 0 1 1 0 0Group of 4-bits 8 4 2 1 8 4 2 1 8 4 2 1Denary value 5 10 12Hexadecimal digits 5 A CHence, denary number 145210 = 5AC16 Hexadecimal number.
Q10. Give reason why programers prefers to use hexadecimal number.
Q11. Give 5 uses of hexadecimal number.
Note : Memory dump refers to the memory contents, output to a printer or monitor to trace errors in programs.
Addition of Binary numbers
Note the following key facts when carrying out addition of two binary digits :
Add Binary digits Denary value Binary equivalent Carry Sum 0 + 0 0 00 0 0 0 + 1 1 01 0 1 1 + 1 2 10 1 0 0 + 0 + 0 0 00 0 0 0 + 0 + 1 1 01 0 1 0 + 1 + 1 2 10 1 0 1 + 1 + 1 3 11 1 1
Q12. a) Convert denary number 126 and 62 into binary.
128 64 32 16 8 4 2 1 Binary of 12610 = 0 1 1 1 1 1 1 0
128 64 32 16 8 4 2 1 Binary of 6210 = 0 0 1 1 1 1 1 0
b) Add the two binary values in 'part a' and check the result matches the addition of the two denary numbers.
1 1 1 1 1 1 ← Carry 0 1 1 1 1 1 1 0 + 0 0 1 1 1 1 1 0 1 0 1 1 1 1 0 0← Sum ⇒ The sum of the two binary is 10111100, whose denary value is 188 (i.e. 128 + 32 + 16 + 8 + 4), which is the same as 126 + 62 = 188.
Q13. Carry out the following 8-bit binary addition and comment on your answer.
a) 0 1 1 0 1 1 1 0 + 1 1 0 1 1 1 1 0
1 1 1 1 1 1 ← Carry 0 1 1 0 1 1 1 0 + 1 1 0 1 1 1 1 0 1 0 1 0 0 1 1 0 0← Sum ⇒ This addition has generated a 9th bit.
⇒ The 8-bits of answer is 01001100, whose denary value is 76 (i.e. 64+8+4) which is incorrect because the denary value of the addition is 110 + 222 = 332.
⇒ The maximum denary value of an 8-bit binary is 255 (i.e. 28-1). The generation of 9th bit indicates that the sum has exceeded this value. This is known as an 'Overflow Error'.
b) 0 1 1 0 0 1 0 0 + 0 0 1 0 1 0 0 0
1 1 ← Carry 0 1 1 0 0 1 0 0 + 0 0 1 0 1 0 0 0 1 0 0 0 1 1 0 0← Sum ⇒ The sum of the two binary is 10001100, whose denary value is 140 (i.e. 128 + 8 + 4), which is the same as 100 + 40 = 140.
Logical binary shifts
Logic shift means, moving bits of a binary number 'n' places towards 'Left' or 'Right'. As bits are shifted, any empty positions are replaced with a zero.
Q14. An 8-bit binary register contains the following value :
0 0 1 1 0 1 0 0
a) Write down the denary value of the reigster.
128 64 32 16 8 4 2 1 0 0 1 1 0 1 0 0⇒ The denary value is 52 (i.e. 32 + 16 + 4).
b) The contents of the register undergo a logical shift one place to the right.
(i) Show the result of this shift :
0 0 0 1 1 0 1 0
(ii) Write down the denary value of your answer to part (b)(i).
128 64 32 16 8 4 2 1 0 0 0 1 1 0 1 0⇒ The denary value is 26 (i.e. 16 + 8 + 2).
(iii) What effect did the shift have on the original denary number when shifted one place to the right?
⇒ The oniginal number is 52 is divided by 2.
(iv) The register in part (b)(i) now undergoes a further logical shift one place to the right.
Show the result of this shift and write down its denary value.
128 64 32 16 8 4 2 1 0 0 0 0 1 1 0 1⇒ The denary value is 13 (i.e. 8 + 4 + 1).
(v) What effect did the shift have on the original denary number when shifted two places to the right?
⇒ The oniginal number is 52 is divided by 22.
(vi) The register in part (b)(i) now undergoes a further logical shift two places to the right.
Comment on your result.
128 64 32 16 8 4 2 1 0 0 0 0 0 1 1 01
⇒ The left most 1-bit has been lost.
⇒ In our 8-bit register, the result of logical shift three places to the right should be 52 ÷ 23 = 6.5, but it is 6 which is clearly incorrect.
⇒ This is called 'Overflow Error', which happened because it has exceeded the maximum number of right shifts possible using this 8-bit register.
c) The contents of the register for denary value 52 undergo a logical shift one place to the left.
0 0 1 1 0 1 0 0
(i) Show the result of this shift :
0 1 1 0 1 0 0 0
(ii) Write down the denary value of your answer to part (b)(i).
128 64 32 16 8 4 2 1 0 1 1 0 1 0 0 0⇒ The denary value is 104 (i.e. 64 + 32 + 8).
(iii) What effect did the shift have on the original denary number when shifted one place to the left?
⇒ The oniginal number is 52 is multiplied by 2.
(iv) The register in part (c)(i) now undergoes a further logical shift one place to the left.
Show the result of this shift and write down its denary value.
128 64 32 16 8 4 2 1 1 1 0 1 0 0 0 0⇒ The denary value is 208 (i.e. 128 + 64 + 16).
(v) What effect did the shift have on the original denary number when shifted two places to the left?
⇒ The oniginal number is 52 is multiplied by 22.
(vi) The register in part (c)(i) now undergoes a further logical shift two places to the left.
Comment on your result.
128 64 32 16 8 4 2 1 1 1 0 1 0 0 0 0 0
⇒ The right most 1-bit has been lost.
⇒ In our 8-bit register, the result of logical shift three places to the left should be 52 x 23 = 416, but it is 160 which is clearly incorrect.
⇒ This is called 'Overflow Error', which happened because it has exceeded the maximum number of left shifts possible using this 8-bit register.
Two's Complement representation of signed (positive and negative) numbers
Two's Complement method is used to represent signed numbers in computer.
To convert positive denary number into two's complement binary formate.
To convert negative denary number into two's complement binary formate.
Q15. A computer system uses two’s complement notation.
a) Complete the headings or positional value for an 8-bit binary number which uses two's complement.
-12864 32 16 8 4 2 1
b) Convert the following binary numbers which uses two's complement into denary numbers.
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
(i) | 1 |
1 |
0 |
0 |
1 |
1 |
0 |
1 |
⇒ The denary value is - 51 (i.e. -128 + 64 + 8 + 4 + 1).
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
(ii) | 0 |
1 |
1 |
0 |
1 |
0 |
0 |
1 |
⇒ The denary value is 105 (i.e. 64 + 32 + 8 + 1).
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
(iii) | 1 |
0 |
1 |
0 |
1 |
1 |
1 |
1 |
⇒ The denary value is - 81 (i.e. -128 + 32 + 8 + 4 + 2 + 1).
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
(iv) | 1 |
1 |
1 |
1 |
1 |
0 |
0 |
1 |
⇒ The denary value is - 7 (i.e. -128 + 64 + 32 + 16 + 8 + 1).
c) Convert the following denary numbers into 8-bit binary numbers which use the two's complement format.
(i) + 47
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 |
0 |
1 |
0 |
1 |
1 |
1 |
1 |
⇒ Take left-most bit as Zero to make it positive.
⇒ Convert positive denary number 47 into binary at remaining bit positions.
(ii) - 59
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 |
1 |
0 |
0 |
0 |
1 |
0 |
1 |
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
⇒ The positive denary value of 59 is - |
0 | 0 | 1 | 1 | 1 | 0 | 1 | 1 |
Carry → | |||||||||
⇒ Invert each binary digits of the number - |
1 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | |
⇒ Add 1 to the number - |
+ | 1 | |||||||
1 |
1 |
0 |
0 |
0 |
1 |
0 |
1 |
d) (i) Convert the denary number +45 into binary, using the two's complement format.
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 |
0 |
1 |
0 |
1 |
1 |
0 |
1 |
⇒ Take left-most bit as Zero to make it positive.
⇒ Convert positive denary number 45 into binary at remaining bit positions.
(ii) Convert the denary number - 45 into binary, using the two's complement format.
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 |
1 |
0 |
1 |
0 |
0 |
1 |
1 |
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | |
⇒ The positive denary value of 45 is - |
0 | 0 | 1 | 0 | 1 | 1 | 0 | 1 |
Carry → | |||||||||
⇒ Invert each binary digits of the number - |
1 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | |
⇒ Add 1 to the number - |
+ | 1 | |||||||
1 |
1 |
0 |
1 |
0 |
0 |
1 |
1 |
(iii) Add together the binary numbers found in part (d)(i) and part (d)(ii), leaving your answer in binary. Comment on the result.
1 1 1 1 1 1 1 1 ← Carry Denary +45 in binary ⇒ 0 0 1 0 1 1 0 1 Denary - 45 in binary ⇒ + 1 1 0 1 0 0 1 1 1 0 0 0 0 0 0 0 0← Sum ⇒ The sum of the two binary number has generated an additional left-most 9th carry bit.
⇒ Discarding the carry bit, the 8-bit sum of two binary number is 0, which is correct (i.e. + 45 + (- 45) = 0).
e) Write down the most negative and most positive numbers that can be stored in an 8-bit register which uses two's complement. Give your answer in both denary and binary.
(i) most negative binary value :
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
most negative denary value :
⇒ - 128 (i.e. left-most positional or header value => -2(8-1) = -27 = - 128).
(ii) most positive binary value :
-128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
0 |
1 |
1 |
1 |
1 |
1 |
1 |
1 |
most positive denary value :
⇒ 127 (i.e. maximum value of 7-bits => 2(8-1) - 1 = 27 - 1 = 128 - 1 = 127).
Q16. Convert and add the denary numbers 120 and 12 using two's complement format. Comment of the result.
1 1 1 1 ← Carry Binary representation of 12010 ⇒ 0 1 1 1 1 0 0 0 Binary representation of 1210 ⇒ + 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 0← Sum ⇒ The sign bit of the result is incorrect, the result of the sum is -124 (i.e. - 128 + 4) which is incorrect. The result has to be 120 + 12 = 132.
⇒ Overflow error has occured, because the sum of the denary has exceeded the maximum positive limit of 8-bit two's complement value of 127.
REVISION : Statements and its key computing terms.
The basic computing element that is either 0 or 1, and is formed from the word Binary digit - | Bit |
The right-most binary digit of a binary number is called - | Least significant bit |
The left-most binary digit of a binary number is called - | Most significant bit |
The maximum number of different values, a N-bit register can hold is | 2N |
The largest decimal value, a N-bit register can hold is - | 2N - 1 |
An operation that shifts bits to the left or right in a register; any empty position are replaced with zero | Logical shift |
Shifting binary number 'X' places towards left is equivalent to - | multiplying the binary number by 2X |
Shifting binary number 'X' places towards right is equivalent to - | dividing the binary number by 2X |
A method of representing negative numbers in binary; the left-most bit of N-bit system is given the negative value -2N-1 (in 8-bit system, the value is -128) | Two's complement |
Positive binary number in two's complement starts with - | Zero bit |
Negative binary number in two's complement starts with - | One bit |
The smallest positive number in two's complement is - | the smallest binary value |
The largest positive number of N-bit system in two's complement is - | 2(N-1) - 1 |
The smallest negative number in two's complement is - | - 2(N-1) |
The result of carrying out a calculation that produces a value that is too large for the computer's allocated word size (8-bit, 16-bit, 32-bit and so on) | Overflow error |
Overflow error in two's complement is determined by the result of calculation with | wrong sign bit |